#include <vector>
#include<iostream>
using namespace std;
class Solution
{
public:
    bool PredictTheWinner(vector<int> &nums)
    {
        int n = nums.size();
        vector<vector<int>> dp(n, vector<int>(n, 0));
        for (int i = 0; i < n; i++)
        {
            dp[i][i] = nums[i];
        }
        for (int i = 1; i < n; i++)
        {
            // step = i
            for (int j = 0; j < n - i; j++)
            {
                // j = start point
                dp[j][j + i] = max(nums[j] - dp[j + 1][j + i], nums[j + i] - dp[j][j + i - 1]);
            }
        }
        return dp[0][n - 1] >= 0;
    }
};
int main(int argc, char const *argv[])
{
    Solution s;
    vector<int> v = {1, 5, 233, 7};
    cout << s.PredictTheWinner(v);
    return 0;
}
